package com.newthread.jdp.dao.impl;

import javax.annotation.Resource;

import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.stereotype.Component;

import com.newthread.jdp.dao.MessageDAO;
import com.newthread.jdp.model.Message;

@Component
public class MessageDAOImpl implements MessageDAO {
	private HibernateTemplate hibernateTemplate;

	@Override
	public void saveMessage(Message msg) {
		hibernateTemplate.save(msg);
	}

	@Resource
	public void setHibernateTemplate(HibernateTemplate hibernateTemplate) {
		this.hibernateTemplate = hibernateTemplate;
	}

	@Override
	public Message querryMessageById(int id) {
		return (Message) hibernateTemplate.get(Message.class, id);
	}

	@Override
	public void updateMessage(Message msg) {
		hibernateTemplate.update(msg);
	}
}
